<!doctype html>
<html class="no-js fixed-layout">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>常德市前列腺疾病研究所</title>
  <meta name="description" content="常德市前列腺疾病研究所">
  <meta name="keywords" content="index">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <link rel="icon" type="image/png" href="/assets/i/favicon.png">
  <link rel="apple-touch-icon-precomposed" href="/assets/i/app-icon72x72@2x.png">
  <meta name="apple-mobile-web-app-title" content="Amaze UI" />
  <link rel="stylesheet" href="/assets/css/amazeui.min.css"/>
  <link rel="stylesheet" href="/assets/css/admin.css">
  <!--引入wangEditor.css-->
<link rel="stylesheet" type="text/css"
	href="/wangediter/css/wangEditor.min.css">

</head>
<body>
<!--[if lte IE 9]>
<p class="browsehappy">你正在使用<strong>过时</strong>的浏览器，Amaze UI 暂不支持。 请 <a href="http://browsehappy.com/" target="_blank">升级浏览器</a>
  以获得更好的体验！</p>
<![endif]-->
#if(graduate.content??==null)
#set(content='<p><br></p>')
#else
#set(content=graduate.content??)
#end
#if(session.username??==null)

<div class="admin-content">
    <div class="admin-content-body">
      <div class="am-cf am-padding am-padding-bottom-0">
        <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg"><a href="/admin/login">请先登录</a></strong></div>
      </div>
    </div>
    </div>

#else
#@top()
#define topcontent()
#end

<div class="am-cf admin-main">
#@left()
#define leftcontent()
#end

<!-- content start -->
  <div class="admin-content">
    <div class="admin-content-body">
      <div class="am-cf am-padding am-padding-bottom-0">
        <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">#(title)</strong> / <small>Personal information</small></div>
      </div>

      <hr/>

      <div class="am-g">
        <div class="am-u-sm-12 am-u-md-12 am-u-md-pull-12">
          <form class="am-form am-form-horizontal">
            <div class="am-form-group">
              <div class="am-u-sm-12" id="div1" style="height: 500px; max-height: 600px;">
              </div>
            </div>

            <div class="am-form-group">
              <div class="am-u-sm-12 am-u-sm-push-6">
                <button type="button" class="am-btn am-btn-primary" id="btn1">保存修改</button>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>

    <footer class="admin-content-footer">
      <hr>
      <p class="am-padding-left">© 2017 weirdor.</p>
    </footer>

  </div>
  <!-- content end -->

</div>

<a href="#" class="am-icon-btn am-icon-th-list am-show-sm-only admin-menu" data-am-offcanvas="{target: '#admin-offcanvas'}"></a>
#end
<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="assets/js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="/assets/js/jquery.min.js"></script>
<!--<![endif]-->
<script src="/assets/js/amazeui.min.js"></script>
<script src="/assets/js/app.js"></script>
<!--引入jquery和wangEditor.js-->
<!--注意：javascript必须放在body最后，否则可能会出现问题-->
<script type="text/javascript"
<script type="text/javascript" src="/wangediter/js/wangEditor.min.js"></script>
<!--引用plupload.full.min.js-->
	<script type="text/javascript"
		src="/wangediter/plupload/lib/plupload.full.min.js"></script>
		<script type="text/javascript">
    var editor = new wangEditor('div1');
    $('#btn1').click(function () {
        // 获取编辑器区域完整html代码
        var html = editor.$txt.html();
        $.ajax({
    		cache: true,
    		type: "POST",
    		url:'/admin/graduatemessage/save',
    		data:{"content":html,"status":#(graduate.status)},
    		async: false,
    		error: function(request) {
    			alert("Connection error");
    		},
    		success: function(data) {
    		
    			if(data.err ==2){
    			
    				alert("错误！");
    			}
    			else{
    				window.location.href='/admin/graduatemessage?status=#(graduate.status)';
    			}
    		}
    	});
    });
</script>
	<!--引用wangEditor.js-->
	<script type="text/javascript">
		// 封装console.log
		function printLog(title, info) {
			window.console && console.log(title, info);
		}

		// ------- 配置上传的初始化事件 -------
		function uploadInit() {
			// this 即 editor 对象
			var editor = this;
			// 编辑器中，触发选择图片的按钮的id
			var btnId = editor.customUploadBtnId;
			// 编辑器中，触发选择图片的按钮的父元素的id
			var containerId = editor.customUploadContainerId;

			//实例化一个上传对象
			var uploader = new plupload.Uploader({
				browse_button : btnId, // 选择文件的按钮的id
				multipart : true,
				url : '/upload', // 服务器端的上传地址
				flash_swf_url : '/wangediter/plupload/lib/Moxie.swf',
				sliverlight_xap_url : '/wangediter/plupload/lib/Moxie.xap',
				filters : {
					mime_types : [
					//只允许上传图片文件 （注意，extensions中，逗号后面不要加空格）
					{
						title : "图片文件",
						extensions : "jpg,gif,png,bmp"
					} ]
				}
			});
			//存储所有图片的url地址
			var urls = [];

			//初始化
			uploader.init();

			//绑定文件添加到队列的事件
			uploader.bind('FilesAdded', function(uploader, files) {
				//显示添加进来的文件名
				$.each(files, function(key, value) {
					printLog('添加文件' + value.name);
				});

				// 文件添加之后，开始执行上传
				uploader.start();
			});

			//单个文件上传之后
			uploader.bind('FileUploaded', function(uploader, file,
					responseObject) {
				//注意，要从服务器返回图片的url地址，否则上传的图片无法显示在编辑器中
				var url = responseObject.response;
				//先将url地址存储来，待所有图片都上传完了，再统一处理
				urls.push(url);

				printLog('一个图片上传完成，返回的url是' + url);
			});

			//全部文件上传时候
			uploader.bind('UploadComplete', function(uploader, files) {
				printLog('所有图片上传完成');

				// 用 try catch 兼容IE低版本的异常情况
				try {
					//打印出所有图片的url地址
					$.each(urls, function(key, value) {
						var dataset = $.parseJSON(value);
						printLog('即将插入图片' + dataset);
						// 插入到编辑器中
						editor.command(null, 'insertHtml', '<img src="'
								+ dataset.fileName
								+ '" style="max-width:100%;"/>');
					});
				} catch (ex) {
					// 此处可不写代码
				} finally {
					//清空url数组
					urls = [];

					// 隐藏进度条
					editor.hideUploadProgress();
				}
			});

			// 上传进度条
			uploader.bind('UploadProgress', function(uploader, file) {
				// 显示进度条
				editor.showUploadProgress(file.percent);
			});
		}
		// ------- 创建编辑器 -------
		var editor = new wangEditor('div1');
		// 插入代码时的默认语言
		editor.config.codeDefaultLang = 'java'
			// 初始化编辑器的内容
			
		
		editor.config.customUpload = true; // 配置自定义上传的开关
		editor.config.customUploadInit = uploadInit; // 配置上传事件，uploadInit方法已经在上面定义了
		editor.create();
		
		editor.$txt.html('#(content)');
	</script>
</body>
</html>
